import { Component, Input, OnInit, ViewChild } from '@angular/core';
import { _HttpClient } from '@delon/theme';
import { SimpleTableColumn, SimpleTableComponent } from '@delon/abc';
import { SFSchema } from '@delon/form';
import { MoonCakeService } from '@core/routes-services/moon-cake.service';
import { ActivityProductService } from '@core/routes-services/activity-product.service';
import { OrderViewComponent } from '../../order/order-view/order-view.component';
import { ORDER_STATUS_OPTION, USER_ROLE_OPTION } from '../../../constant/dictionary';
import { MyModalHelper } from '@core/my-modal.helper';
import { CakeOrderViewComponent } from '../../mid-autumn/cake-order/order-view/cake-order-view.component';
import { FinancesService } from '@core/routes-services/finances.service';
import { OrderService } from '@core/routes-services/order.service';
import { ActivatedRoute } from '@angular/router';
import { NzMessageService } from 'ng-zorro-antd';
import { MarketFansService } from '@core/routes-services/market-fans.service';

@Component({
  selector: 'app-salesman-team',
  templateUrl: './salesman-team.component.html',
})
export class SalesmanTeamComponent implements OnInit {

  @Input() salesmanId:any;
  isLoading = false;
  keyword: any;
  page: any = { number: 1, size: 10, totalElements: 0, content: [] };

  constructor(private message: NzMessageService,
              private route: ActivatedRoute,
              private marketFansService: MarketFansService,
              private modalHelper: MyModalHelper) {
  }

  ngOnInit() {
    this.initPage();
  }


  initPage() {
    this.isLoading = true;
    this.marketFansService.teamPagination(this.page, this.keyword, this.salesmanId).then((res) => {
      console.log(res);
      if (res.status.toString().startsWith('20')) {
        this.page = res.data;
        ++this.page.number;
      } else {
        this.message.warning(res.message);
      }
      this.isLoading = false;
    }, error => {
      this.message.error(error.message ? error.message : error.error);
      this.isLoading = false;
    });
  }

  /**
   * 搜索重置分页数据
   */
  search() {
    this.page = { number: 0, size: 10, totalElements: 0, content: [] };
    this.initPage();
  }

  changePageNo(pageNo) {
    this.page = { number: pageNo, size: 10, totalElements: 0, content: [] };
    this.initPage();
  }



}
